/*
 * message
 *
 * $Id: msg.h 14 2008-12-16 09:01:52Z ybc2084 $
 */

#ifndef _MSG_H_
#define _MSG_H_

#ifdef	__cplusplus
extern "C" {
#endif

#include <unistd.h>
#include <mad.h>

/**************************************************************
 * mesg def for decoder
 **************************************************************/

/*
 * message type def for decoder
 */
typedef enum {
	DEC_NEWFILE	= 0,
	DEC_PAUSE,
	DEC_RESUME,
	DEC_START,
	DEC_STOP,
	DEC_EXIT,
	DEC_FINISH,
	DEC_EXCEPT,
	DEC_AUDIO,

	DEC_INVALID,	/* as sentinel */
} DEC_MSG_TYPE;

/* NEWFILE mesg */
typedef struct {
	DEC_MSG_TYPE	type;
	char			fpath[_POSIX_PATH_MAX];	/* music file path */
} DEC_NEWFILE_MSG;

/* PAUSE mesg */
typedef struct {
	DEC_MSG_TYPE	type;
} DEC_PAUSE_MSG;

/* RESUME mesg */
typedef struct {
	DEC_MSG_TYPE	type;
} DEC_RESUME_MSG;

/* START mesg */
typedef struct {
	DEC_MSG_TYPE	type;
} DEC_START_MSG;

/* STOP mesg */
typedef struct {
	DEC_MSG_TYPE	type;
} DEC_STOP_MSG;

/* EXIT mesg */
typedef struct {
	DEC_MSG_TYPE	type;
} DEC_EXIT_MSG;

/* FINISH mesg */
typedef struct {
	DEC_MSG_TYPE	type;
} DEC_FINISH_MSG;

/* EXCEPT mesg */
typedef struct {
	DEC_MSG_TYPE	type;
} DEC_EXCEPT_MSG;

/* AUDIO mesg */
typedef struct {
	DEC_MSG_TYPE		type;
	struct mad_header	header;	/* XXX: should independent to mad */
	struct mad_pcm		pcm;
} DEC_AUDIO_MSG;

/*
 * decoder message
 * each mesg has a 'type' field, which overlap DEC_MSG.type
 */
typedef union {
	DEC_MSG_TYPE	type;

	DEC_NEWFILE_MSG		newfile;
	DEC_PAUSE_MSG		pause;
	DEC_RESUME_MSG		resume;
	DEC_STOP_MSG		stop;
	DEC_START_MSG		start;
	DEC_EXIT_MSG		exit;
	DEC_FINISH_MSG		finish;
	DEC_EXCEPT_MSG		except;
	DEC_AUDIO_MSG		audio;
} DEC_MSG;

#ifdef	__cplusplus
}
#endif

#endif	/* _MSG_H_*/

